<?php
// application/forms/Tblproduit.php
class Application_Form_Tblproduit extends OMNZend_Form
{
    private $idTblproduit;
    private $logger;

    public function setIdTblproduit($idTblproduit) {
        $this->idTblproduit = $idTblproduit;
    }

    public function getIdTblproduit() {
        return $this->idTblproduit;
    }

    public function init() {

        //->view->headTitle('BBViande - Adresse');
        $this->logger = Zend_Registry::get('logger');
        $this->logger->info("Hello from Application_Form_Tblproduit");

           // Set the method for the display form to POST
           $this->setMethod('post');
  
          
           // Add the Nom element
           $this->addElement('text', 'nom', array(
               'label'      => 'Nom',
               'required'   => true,
               'validators' => array(
                   array('validator' => 'StringLength', 'options' => array(0, 20))
                   )
           ));
           // Add the Designation element
           $this->addElement('text', 'designation', array(
               'label'      => 'Designation',
               'required'   => true,
               'validators' => array(
                   array('validator' => 'StringLength', 'options' => array(0, 20))
                   )
           ));
           // Add the Description element
           $this->addElement('text', 'description', array(
               'label'      => 'Description',
               'validators' => array(
                   array('validator' => 'StringLength', 'options' => array(0, 20))
                   )
           ));

           


           // Add the submit button
           $this->addElement('submit', 'submit', array(
               'ignore'   => true,
               'label'    => 'Add Tblproduit',
           ));


        $this->clearDecorators();
        $this->addDecorator('FormElements')
                ->addDecorator('HtmlTag', array('tag' => '<ul>', 'class' => 'form'))
                ->addDecorator('Form');
        $this->setElementDecorators($this->_defaultDecorator);
        //$this->getElement('company_siret')->setDecorators($this->_inlineDecorator);

        $idTblproduit = $this->getIdTblproduit();
        if (isset($idTblproduit) && $idTblproduit != "") {
            $company = new Application_Model_DbTable_Tblproduit( );

            $company = $company->fetchRow(array("id = ?" => $idTblproduit));
            if ($company != null) {
                $company = $company->toArray();
                $this->populate($company);
                $submit->setLabel('Update Tblproduit');
            } else {
                throw new Zend_Exception("form_Tblproduit_no_id");
            }
        }


       }
}
